#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"

function error {
  echo -e "\\e[91m$1\\e[39m"
  exit 1
}

wget https://github.com/Pi-Apps-Coders/files/raw/main/lightpad_0.0.8rev1_armhf.deb -O ~/lightpad.deb || error "Failed to download lightpad.deb!"

"${DIRECTORY}/pkg-install" "$HOME/lightpad.deb" "$(dirname "$0")" || error 'Failed to install lightpad.deb'

rm -f ~/lightpad.deb

echo "[Desktop Entry]
Version=1.0
Type=Application
Name=Lightpad
Icon=lightpad
Exec=com.github.libredeb.lightpad
Comment=LightPad is a lightweight, simple and powerful application launcher
Categories=Accessories;Utility;
Terminal=false" > ~/.local/share/applications/lightpad.desktop


